package mapper.dao;

import mapper.base.BaseMapper;
import mapper.entity.SqlInfo;
import mapper.entity.TestInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;

@Mapper
@Repository
public interface TestDao extends BaseMapper<TestInfo> {
    @Select("select * from test where id=#{id}")
    TestInfo findTestById(@Param("id") Integer id);

    @Select("select * from test")
    List<TestInfo> findTestList();

    @Select("select count(*) from test")
    int count();

    @Insert({
            "insert into test ",
            "(name, description)",
            " values ",
            "(#{name}, #{description})",
    })
    int insert(TestInfo entity);

    @Delete("delete test where id=#{id}")
    int delete(@Param("id") Integer id);

    @Update({
            "update test set ",
            "name=#{name}",
            "description=#{description}",
    })
    int update(TestInfo entity);

    @Select("${sql}")
    List<TestInfo> query(SqlInfo sql);
}
